package com.lingxi.d1_2;

import java.io.*;
public class copy
{
    public static void main(String[] args)
    {
        try(
                FileInputStream fi = new FileInputStream("C:\\PGtest\\javastaircase\\study\\Study\\src\\com\\lingxi\\d1_2\\source.txt");
                FileOutputStream fo = new FileOutputStream("C:\\PGtest\\javastaircase\\study\\Study\\src\\com\\lingxi\\d1_2\\dest.txt");
                )
        {
            byte[] buffer = new byte[1024];
            int bytesRead;
            while ((bytesRead = fi.read(buffer)) != -1)
            {
                fo.write(buffer, 0, bytesRead);
            }
        } catch (FileNotFoundException e)
        {
            System.err.println("打开时发生错误.");
            e.printStackTrace();
        } catch (IOException e)
        {
            System.err.println("复制时发生错误.");
            e.printStackTrace();
        }
    }
}
